﻿using DAL;
using IService;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Service
{
    public class WhTransferService : IWhTransferService
    {
        private readonly WhTransferDal dal;
        public WhTransferService(WhTransferDal dal)
        {
            this.dal = dal;
        }

        /// <summary>
        /// 调拨单添加（含明细和附件）
        /// </summary>
        /// <param name="mainModel"></param>
        /// <param name="detailList"></param>
        /// <param name="attachmentList"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<int> AddWhTransferOrderInfo(WhTransferModelWithMain mainModel, List<WhTransferModelWithDetail> detailList, List<SysAttachmentDTO> attachmentList = null)
        {
            return dal.AddWhTransferOrderInfo(mainModel, detailList, attachmentList);
        }

        /// <summary>
        /// 审核调拨单
        /// </summary>
        /// <param name="am"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public int AuditeTransferOrder(AuditerModel am)
        {
            return dal.AuditeTransferOrder(am);
        }

        /// <summary>
        /// 根据库位ID、仓库ID和商品ID查询该库位该商品的库存数量
        /// </summary>
        /// <param name="locationId"></param>
        /// <param name="warehouseId"></param>
        /// <param name="goodsId"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<decimal> FindLocationQuantity(long locationId, long warehouseId, long goodsId)
        {
            return dal.FindLocationQuantity(locationId, warehouseId, goodsId);
        }

        public List<GetAllWhTransfer> GetAllTransferOrderInfo()
        {
            return dal.GetAllTransferOrderInfo();
        }

        /// <summary>
        /// 根据调出仓库ID和调入仓库ID获取调拨商品信息
        /// </summary>
        /// <param name="outStockId"></param>
        /// <param name="inStockId"></param>
        /// <returns></returns>
        public Task<List<WhTransferForAddWhTDetail>> GetTransferGoodsInfo(long outStockId, long inStockId)
        {
            return dal.GetTransferGoodsInfo(outStockId, inStockId);
        }
        
        /// <summary>
        /// 多条件查询调拨单
        /// </summary>
        /// <param name="swtwsm"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task<List<GetAllWhTransfer>> SelectTransferOrderWithSth(SelectWhTransferWithSthModel swtwsm)
        {
            return dal.SelectTransferOrderWithSth(swtwsm);
        }
    }
}
